//
//  GHSAD_HHInfoTableViewCell.m
//  penzer
//
//  Created by 还带大道 on 2018/11/22.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSAD_HHInfoTableViewCell.h"

@interface GHSAD_HHInfoTableViewCell()
@property (weak, nonatomic) IBOutlet UIView *bgV;
@property (weak, nonatomic) IBOutlet UILabel *time_apply;
@property (weak, nonatomic) IBOutlet UILabel *reason;
@property (weak, nonatomic) IBOutlet UILabel *desc;
@property (weak, nonatomic) IBOutlet UIView *picV;

@property (nonatomic,strong) NSMutableArray<UIView *> *pics;
@end

@implementation GHSAD_HHInfoTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    //设置阴影
    _bgV.backgroundColor = [UIColor whiteColor];
    _bgV.layer.shadowColor = RZ_COLOR_ALPHA(0, 0, 0, 0.1).CGColor;
    _bgV.layer.cornerRadius = 5;
    _bgV.layer.shadowOffset = CGSizeMake(0,4);
    _bgV.layer.shadowOpacity = 1;
    _bgV.layer.shadowRadius = 15;
    
    [self addImages];
}


- (void)addImages
{
    //    _picV.backgroundColor = [UIColor orangeColor];
    _pics = [NSMutableArray array];
    for (NSInteger index =0;index<3;index++) {
        UIButton *btn = [UIButton new];
        //        btn.backgroundColor = [UIColor greenColor];
        [btn setBackgroundImage:[UIImage imageNamed:@"icon_goods"] forState:UIControlStateNormal];
        [self.picV addSubview:btn];
        [self.pics addObject:btn];
    }
}




- (void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat wh = 80;
    __block CGFloat x = 0;
    __block CGFloat y = 0;
    __block NSInteger row = 0;
    __block NSInteger col = 0;
    NSInteger maxcount = 3;
    CGFloat margin_xy = 10;
    
    [self.pics enumerateObjectsUsingBlock:^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        col = idx % maxcount;
        row = idx / maxcount;
        x = (wh + margin_xy)*col;
        y = (wh + margin_xy)*row;
        obj.frame = CGRectMake(x, y, wh, wh);
    }];
    
    CGFloat height = CGRectGetMinY(self.picV.frame) + CGRectGetMaxY(self.pics.lastObject.frame) +30;
    _cellH = height;
}


- (CGFloat)cellH
{
    [self layoutIfNeeded];
    self.bgV.layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, self.bgV.width, _cellH-12)].CGPath;
    return _cellH;
}

@end
